package com.gsdkjgpt4.sys.service.impl;

import com.gsdkjgpt4.sys.entity.History;
import com.gsdkjgpt4.sys.entity.User;
import com.gsdkjgpt4.sys.mapper.HistoryMapper;
import com.gsdkjgpt4.sys.service.IHistoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author rendong
 * @since 2024-01-18
 */
@Service
public class HistoryServiceImpl extends ServiceImpl<HistoryMapper, History> implements IHistoryService {

    @Override
    public Map<String, Object> selectHistoryByUserId(Integer userId) {
        if (userId != 0) {
            Map<String, Object> data = new HashMap<>();
            List<History> historyList = this.baseMapper.selectHistoryByUserId(userId);
            data.put("historyList", historyList);

            return data;
        }
        return null;
    }

    @Override
    public Map<String, Object> generateHistory(Integer isChatgpt, String context, Integer userId) {
        if(context != null){
            Map<String, Object> data = new HashMap<>();
            this.baseMapper.generateHistory(isChatgpt,context,userId);
            data.put("result",true);

            return data;
        }
        return null;
    }

    @Override
    public Map<String, Object> send() {
        Map<String, Object> data = new HashMap<>();
        data.put("msg","你好！");
        return data;
    }
}
